package com.ssy.lingxi.contract.entity;

import com.ssy.lingxi.contract.handler.converter.JpaJsonToIntegerConverter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 合同
 * @author 伍将
 * @date 2021/1/25
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "con_contract",
        indexes = {@Index(name = "con_contract_party_a_idx", columnList = "partyAMemberId,partyARoleId"),
                @Index(name = "con_contract_party_b_idx", columnList = "partyBMemberId,partyBRoleId"),
                @Index(name = "con_contract_contract_no_idx", columnList = "contractNo"),
                @Index(name = "con_contract_start_time_idx", columnList = "startTime"),
                @Index(name = "con_contract_end_time_idx", columnList = "endTime"),
                @Index(name = "con_contract_outer_status_idx", columnList = "outerStatus"),
                @Index(name = "con_contract_party_a_inner_status_idx", columnList = "partyAInnerStatus"),
                @Index(name = "con_contract_party_b_inner_status_idx", columnList = "partyBInnerStatus")})
public class ContractDO implements Serializable {
    private static final long serialVersionUID = 8311712886946664769L;

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contract_seq")
    @SequenceGenerator(sequenceName = "con_contract_seq", name = "contract_seq", allocationSize = 1)
    private Long id;

    /**
     * 甲方会员id
     */
    @Column(columnDefinition = "int8")
    private Long partyAMemberId;

    /**
     * 甲方角色id
     */
    @Column(columnDefinition = "int8")
    private Long partyARoleId;

    /**
     * 甲方名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String partyAName;

    /**
     * 乙方会员id
     */
    @Column(columnDefinition = "int8")
    private Long partyBMemberId;

    /**
     * 乙方角色id
     */
    @Column(columnDefinition = "int8")
    private Long partyBRoleId;

    /**
     * 乙方名称
     */
    @Column(columnDefinition = "varchar(50)")
    private String partyBName;

    /**
     * 合同编号
     */
    @Column(columnDefinition = "varchar(16)")
    private String contractNo;

    /**
     * 合同摘要
     */
    @Column(columnDefinition = "varchar(60)")
    private String contractAbstract;

    /**
     * 合同有效开始时间
     */
    @Column(columnDefinition = "int8")
    private Long startTime;

    /**
     * 合同有效结束时间
     */
    @Column(columnDefinition = "int8")
    private Long endTime;

    /**
     * 合同总金额
     */
    @Column(columnDefinition = "decimal")
    private Double totalAmount;

    /**
     * 合同剩余金额（=合同总金额-合同相关采购单累计金额[不含取消的]）
     */
    @Column(columnDefinition = "decimal")
    private Double freeAmount;

    /**
     * 执行金额
     */
    @Column(columnDefinition = "decimal")
    private Double executeAmount;

    /**
     * 付款金额
     */
    @Column(columnDefinition = "decimal")
    private Double payAmount;

    /**
     * 未支付请款金额
     */
    @Column(columnDefinition = "decimal")
    private Double unPayApplyAmount;

    /**
     * 未请款金额
     */
    @Column(columnDefinition = "decimal")
    private Double unApplyAmount;

    /**
     * 寻源类型：SourceTypeEnum
     */
    @Column(columnDefinition = "int")
    private Integer sourceType;

    /**
     * 寻源单据id
     */
    @Column(columnDefinition = "int8")
    private Long sourceId;

    /**
     * 寻源单据编号
     */
    @Column(columnDefinition = "varchar(16)")
    private String sourceNo;

    /**
     * 投标/报价单据id
     */
    @Column(columnDefinition = "int8")
    private Long supplierSourceId;

    /**
     * 投标/报价单据编号
     */
    @Column(columnDefinition = "varchar(16)")
    private String supplierSourceNo;

    /**
     * 外部工作流类型：ProcessEnum
     */
    @Column(columnDefinition = "int")
    private Integer outerTaskType;

    /**
     * 合同外部状态：ContractOuterStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer outerStatus;

    /**
     * 外部任务id
     */
    @Column(columnDefinition = "varchar(50)")
    private String outerTaskId;

    /**
     * 外部工作流当前步骤
     */
    @Column(columnDefinition = "int")
    private Integer outerTaskStep;

    /**
     * 外部工作流步骤记录
     */
    @Convert(converter = JpaJsonToIntegerConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Integer> outerTaskStepRecord = new ArrayList<>();

    /**
     * 甲方内部工作流类型：ProcessEnum
     */
    @Column(columnDefinition = "int")
    private Integer partyAInnerTaskType;

    /**
     * 甲方内部状态：ContractPartyAInnerStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer partyAInnerStatus;

    /**
     * 甲方内部任务id
     */
    @Column(columnDefinition = "varchar(50)")
    private String  partyAInnerTaskId;

    /**
     * 甲方内部工作流当前步骤
     */
    @Column(columnDefinition = "int")
    private Integer partyAInnerTaskStep;

    /**
     * 甲方内部工作流步骤记录
     */
    @Convert(converter = JpaJsonToIntegerConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Integer> partyAInnerTaskStepRecord = new ArrayList<>();

    /**
     * 乙方内部工作流类型：ProcessEnum
     */
    @Column(columnDefinition = "int")
    private Integer partyBInnerTaskType;

    /**
     * 乙方内部状态：ContractPartyBInnerStatusEnum
     */
    @Column(columnDefinition = "int")
    private Integer partyBInnerStatus;

    /**
     * 甲方内部任务id
     */
    @Column(columnDefinition = "varchar(50)")
    private String  partyBInnerTaskId;

    /**
     * 乙方内部工作流当前步骤
     */
    @Column(columnDefinition = "int")
    private Integer partyBInnerTaskStep;

    /**
     * 乙方内部工作流步骤记录
     */
    @Convert(converter = JpaJsonToIntegerConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Integer> partyBInnerTaskStepRecord = new ArrayList<>();

    /**
     * 旧合同id（变更合同时大于0）
     */
    @Column(columnDefinition = "int8")
    private Long oldContractId = 0L;

    /**
     * 是否提交过：CommonBooleanEnum
     */
    @Column(columnDefinition = "int")
    private Integer isSubmit;

    /**
     * 作废时间
     */
    @Column(columnDefinition = "int8")
    private Long invalidTime;

    /**
     * 作废原因
     */
    @Column(columnDefinition = "varchar(100)")
    private String invalidReason;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8")
    private Long createTime;

    /**
     * 更新时间
     */
    @Column(columnDefinition = "int8")
    private Long updateTime;
    /**
     *轮次(仅询价单)
     */
    @Column(columnDefinition = "int2")
    private Integer turn;
    /**
     * 子合同id（基于当前合同而产生变更合同的id，没有变更则为0）
     * [区别于与oldContractId字段，oldContractId相当于变更合同的源合同id]
     */
    @Column(columnDefinition = "int8")
    private Long subContractId = 0L;

    /**
     * 签署记录id
     */
    private Long signatureLogId;
    /**
     *采购类型:1.单词采购 2.协议采购
     */
    @Column(columnDefinition = "int2")
    private Integer purchaseType;

    public String getOuterTaskId() {
        return outerTaskId;
    }

    public void setOuterTaskId(String outerTaskId) {
        this.outerTaskId = outerTaskId;
    }

    public String getPartyAInnerTaskId() {
        return partyAInnerTaskId;
    }

    public void setPartyAInnerTaskId(String partyAInnerTaskId) {
        this.partyAInnerTaskId = partyAInnerTaskId;
    }

    public String getPartyBInnerTaskId() {
        return partyBInnerTaskId;
    }

    public void setPartyBInnerTaskId(String partyBInnerTaskId) {
        this.partyBInnerTaskId = partyBInnerTaskId;
    }

    public Long getInvalidTime() {
        return invalidTime;
    }

    public void setInvalidTime(Long invalidTime) {
        this.invalidTime = invalidTime;
    }

    public String getInvalidReason() {
        return invalidReason;
    }

    public void setInvalidReason(String invalidReason) {
        this.invalidReason = invalidReason;
    }

    public Integer getIsSubmit() {
        return isSubmit;
    }

    public void setIsSubmit(Integer isSubmit) {
        this.isSubmit = isSubmit;
    }

    public Double getUnPayApplyAmount() {
        return unPayApplyAmount;
    }

    public void setUnPayApplyAmount(Double unPayApplyAmount) {
        this.unPayApplyAmount = unPayApplyAmount;
    }

    public Double getUnApplyAmount() {
        return unApplyAmount;
    }

    public void setUnApplyAmount(Double unApplyAmount) {
        this.unApplyAmount = unApplyAmount;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getPartyAMemberId() {
        return partyAMemberId;
    }

    public void setPartyAMemberId(Long partyAMemberId) {
        this.partyAMemberId = partyAMemberId;
    }

    public Long getPartyARoleId() {
        return partyARoleId;
    }

    public void setPartyARoleId(Long partyARoleId) {
        this.partyARoleId = partyARoleId;
    }

    public String getPartyAName() {
        return partyAName;
    }

    public void setPartyAName(String partyAName) {
        this.partyAName = partyAName;
    }

    public Long getPartyBMemberId() {
        return partyBMemberId;
    }

    public void setPartyBMemberId(Long partyBMemberId) {
        this.partyBMemberId = partyBMemberId;
    }

    public Long getPartyBRoleId() {
        return partyBRoleId;
    }

    public void setPartyBRoleId(Long partyBRoleId) {
        this.partyBRoleId = partyBRoleId;
    }

    public String getPartyBName() {
        return partyBName;
    }

    public void setPartyBName(String partyBName) {
        this.partyBName = partyBName;
    }

    public String getContractNo() {
        return contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }

    public String getContractAbstract() {
        return contractAbstract;
    }

    public void setContractAbstract(String contractAbstract) {
        this.contractAbstract = contractAbstract;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }

    public Double getFreeAmount() {
        return freeAmount;
    }

    public void setFreeAmount(Double freeAmount) {
        this.freeAmount = freeAmount;
    }

    public Double getExecuteAmount() {
        return executeAmount;
    }

    public void setExecuteAmount(Double executeAmount) {
        this.executeAmount = executeAmount;
    }

    public Double getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(Double payAmount) {
        this.payAmount = payAmount;
    }

    public Integer getSourceType() {
        return sourceType;
    }

    public void setSourceType(Integer sourceType) {
        this.sourceType = sourceType;
    }

    public Long getSourceId() {
        return sourceId;
    }

    public void setSourceId(Long sourceId) {
        this.sourceId = sourceId;
    }

    public String getSourceNo() {
        return sourceNo;
    }

    public void setSourceNo(String sourceNo) {
        this.sourceNo = sourceNo;
    }

    public Long getSupplierSourceId() {
        return supplierSourceId;
    }

    public void setSupplierSourceId(Long supplierSourceId) {
        this.supplierSourceId = supplierSourceId;
    }

    public String getSupplierSourceNo() {
        return supplierSourceNo;
    }

    public void setSupplierSourceNo(String supplierSourceNo) {
        this.supplierSourceNo = supplierSourceNo;
    }

    public Integer getOuterTaskType() {
        return outerTaskType;
    }

    public void setOuterTaskType(Integer outerTaskType) {
        this.outerTaskType = outerTaskType;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Integer getOuterTaskStep() {
        return outerTaskStep;
    }

    public void setOuterTaskStep(Integer outerTaskStep) {
        this.outerTaskStep = outerTaskStep;
    }

    public List<Integer> getOuterTaskStepRecord() {
        return outerTaskStepRecord;
    }

    public void setOuterTaskStepRecord(List<Integer> outerTaskStepRecord) {
        this.outerTaskStepRecord = outerTaskStepRecord;
    }

    public Integer getPartyAInnerTaskType() {
        return partyAInnerTaskType;
    }

    public void setPartyAInnerTaskType(Integer partyAInnerTaskType) {
        this.partyAInnerTaskType = partyAInnerTaskType;
    }

    public Integer getPartyAInnerStatus() {
        return partyAInnerStatus;
    }

    public void setPartyAInnerStatus(Integer partyAInnerStatus) {
        this.partyAInnerStatus = partyAInnerStatus;
    }

    public Integer getPartyAInnerTaskStep() {
        return partyAInnerTaskStep;
    }

    public void setPartyAInnerTaskStep(Integer partyAInnerTaskStep) {
        this.partyAInnerTaskStep = partyAInnerTaskStep;
    }

    public List<Integer> getPartyAInnerTaskStepRecord() {
        return partyAInnerTaskStepRecord;
    }

    public void setPartyAInnerTaskStepRecord(List<Integer> partyAInnerTaskStepRecord) {
        this.partyAInnerTaskStepRecord = partyAInnerTaskStepRecord;
    }

    public Integer getPartyBInnerTaskType() {
        return partyBInnerTaskType;
    }

    public void setPartyBInnerTaskType(Integer partyBInnerTaskType) {
        this.partyBInnerTaskType = partyBInnerTaskType;
    }

    public Integer getPartyBInnerStatus() {
        return partyBInnerStatus;
    }

    public void setPartyBInnerStatus(Integer partyBInnerStatus) {
        this.partyBInnerStatus = partyBInnerStatus;
    }

    public Integer getPartyBInnerTaskStep() {
        return partyBInnerTaskStep;
    }

    public void setPartyBInnerTaskStep(Integer partyBInnerTaskStep) {
        this.partyBInnerTaskStep = partyBInnerTaskStep;
    }

    public List<Integer> getPartyBInnerTaskStepRecord() {
        return partyBInnerTaskStepRecord;
    }

    public void setPartyBInnerTaskStepRecord(List<Integer> partyBInnerTaskStepRecord) {
        this.partyBInnerTaskStepRecord = partyBInnerTaskStepRecord;
    }

    public Long getOldContractId() {
        return oldContractId;
    }

    public void setOldContractId(Long oldContractId) {
        this.oldContractId = oldContractId;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getTurn() {
        return turn;
    }

    public void setTurn(Integer turn) {
        this.turn = turn;
    }

    public Long getSubContractId() {
        return subContractId;
    }

    public void setSubContractId(Long subContractId) {
        this.subContractId = subContractId;
    }

    public Long getSignatureLogId() {
        return signatureLogId;
    }

    public void setSignatureLogId(Long signatureLogId) {
        this.signatureLogId = signatureLogId;
    }

    public Integer getPurchaseType() {
        return purchaseType;
    }

    public void setPurchaseType(Integer purchaseType) {
        this.purchaseType = purchaseType;
    }
}
